package com.woniu.utils;

import cn.hutool.jwt.JWTUtil;
import com.woniu.dto.UserDto;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

public class UserUtil {

    public static UserDto getUserInfo() {
        ServletRequestAttributes requestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
        return JWTUtil.parseToken(requestAttributes.getRequest().getHeader("JWToken")).getPayloads().toBean(UserDto.class);
    }
}

